package eft.android.controller;

public class Workout {
	private long _id;
	private int type;
	private String title;
	private String description;
	private long date;
	private String weight;
	private String reps;
	private long time;
	private String notes;
	
	public Workout()
	{
		this._id = 0;
		this.type = 0;
		this.title = null;
		this.description = null;
		this.date = 00000000;
		this.weight = null;
		this.reps = null;
		this.time = 000000;
		this.notes = null;
		
	}
	
	
	public Workout(long _id, int type, String title, String description, long date, String weight, String reps, long time, String notes)
	{
		this._id = _id;
		this.type = type;
		this.title = title;
		this.description = description;
		this.date = date;
		this.weight = weight;
		this.reps = reps;
		this.time = time;
		this.notes = notes;
	}
	//set and get methods
	public void setID(long _id)
	{ this._id = _id; }
	
	public long getID()
	{ return _id; }
		
	public void setType(int type) {
		this.type = type;
	}
	
	public int getType()
	{ return type; }

	public void setTitle(String title) {
		this.title = title;
	}

	public String getTitle() {
		return title;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return description;
	}

	public void setWeight(String weight) {
		this.weight = weight;
	}

	public String getWeight() {
		return weight;
	}

	public void setReps(String reps) {
		this.reps = reps;
	}

	public String getReps() {
		return reps;
	}

	public void setDate(long date) {
		this.date = date;
	}

	public long getDate() {
		return date;
	}

	public void setTime(long time) {
		this.time = time;
	}

	public long getTime() {
		return time;
	}
	
	public String getDateReadable(){
		String s = ((Long) getDate() ).toString();
		int year = Integer.parseInt( s.substring(0,4) );
		int month = Integer.parseInt( s.substring(4,6) );
		int day = Integer.parseInt( s.substring(6,8) );
		
		String mon = getMonth(month).substring(0 , 3);
		
		return mon + " " + day + ", " + year;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public String getNotes() {
		return notes;
	}
	
	
	private String getMonth(int month)
	{
		String monthStr;
		switch(month)
		{
		case 1:
			monthStr = "January ";
			break;
		case 2:
			monthStr = "February ";
			break;
		case 3:
			monthStr = "March ";
			break;
		case 4:
			monthStr = "April ";
			break;
		case 5:
			monthStr = "May ";
			break;
		case 6:
			monthStr = "June ";
			break;
		case 7:
			monthStr = "July ";
			break;
		case 8:
			monthStr = "August ";
			break;
		case 9:
			monthStr = "September ";
			break;
		case 10:
			monthStr = "October ";
			break;
		case 11:
			monthStr = "November ";
			break;
		case 12:
			monthStr = "December ";
			break;
		default:
			monthStr = "Error ";
			break;
		}

		return monthStr;
	}
	
	public String getTimeReadable()
	{
		String timeStr;
		long centi;
		long secs;
		long min;
		min = this.getTime() / 6000;
		secs = (this.getTime() % 6000) / 100;
		centi = (this.getTime() % 6000) % 100;
		timeStr = "" + min + ":" + secs + "." + centi;
		return timeStr;
	}
	
}
